﻿@model IEnumerable<MinistryStandardPlatformWeb.Models.UnitTaskModel>

<script type="text/javascript" src="~/Scripts/jquery-easyui/jquery.easyui.min.js"></script>
<link type="text/css" href="~/Scripts/jquery-easyui/themes/default/easyui.css" rel="stylesheet" />
<link type="text/css" href="~/Scripts/jquery-easyui/themes/icon.css" rel="stylesheet" />
<script type="text/javascript">
    $(document).ready(function () {
        $("#tt").tabs({
            onSelect: function () {
                $(".panel>div").height($(".panel:visible").height());
            }
        });

        $(".tabs-panels").addClass("box");
        $(".tabs-panels").addClass("verticalbox");
        $(".tabs-panels").addClass("fillparentheight");
        $(".panel").addClass("fillparentheight");
        //$(".panel").css("overflow", "auto");

        $(".panel>div").height($(".panel:visible").height());

        $(window).resize(function () {
            $(".panel>div").width($(this).width());

            //setTimeout(resizeDiv, 500);
            $(".panel>div").height($(".panel:visible").height());
        });


        //function resizeDiv() {
        //    $(".panel>div").height($(".panel").height());
        //}

        $("#unittasktable tr:gt(0)").dblclick(function () {
            //var content = '<iframe scrolling="auto" frameborder="0"  src="/DispatchCenter/Detail/' + $(this).attr("id") + '" style="width:100%;height:100%;"></iframe>';
            //$('#tt').tabs('add', {
            //    title: $(this).children().eq(0).html()+'任务详情',
            //    href: '/DispatchCenter/Detail/' + $(this).attr("id"),
            //    //content: content,
            //    cache: false,
            //    closable: true
            //});
            var id = $(this).attr("id");
            var title = $(this).children().eq(0).html() + '任务详情';
            if ($("#tt").tabs('exists', title)) {
                $("#tt").tabs('select', title)
            }
            else {
                myajax('/DispatchCenter/Detail',
                        id,
                        function (data) {
                            $('#tt').tabs('add', {
                                title: title,
                                //href: '/DispatchCenter/Detail/' + $(this).attr("id"),
                                content: data,
                                closable: true
                            });

                            $(".tabs-panels").addClass("box");
                            $(".tabs-panels").addClass("verticalbox");
                            $(".tabs-panels").addClass("fillparentheight");
                            $(".panel").addClass("fillparentheight");
                            //$(".panel").css("overflow", "auto");
                            $(".panel>div").height($(".panel:visible").height());
                        },
                        function (data) {
                            //artDialogAlert("删除失败");
                            artDialogAlert("请求失败");
                        },
                        "",
                        false
                        );
            }
        });

        //调整静态表头的宽度
        $("#unittasktable thead tr th").each(function (index) {
            $("#unittasktableheader thead tr th").eq(index).width($(this).width()+1);
        });
    });

</script>
<div class="fillparentheight easyui-tabs box verticalbox" id="tt">
    <div class="" title="各单位任务统计" data-options="closable:false">
        <div style="overflow:auto;">
        <table id="unittasktableheader" class="tablelist">
            <thead style="position:absolute;">
                <tr>
                    <th>单位名称</th>
                    <th>车辆数</th>
                    <th>任务单数</th>
                    <th>正在进行任务车辆数</th>
                    <th>空闲车辆数</th>
                    <th>不可用车辆数</th>
                    <th>月累计趟数</th>
                    <th>月运输总量</th>
                </tr>
            </thead>
        </table>
        <table id="unittasktable" class="tablelist">
            <thead>
                <tr>
                    <th>单位名称</th>
                    <th>车辆数</th>
                    <th>任务单数</th>
                    <th>正在进行任务车辆数</th>
                    <th>空闲车辆数</th>
                    <th>不可用车辆数</th>
                    <th>月累计趟数</th>
                    <th>月运输总量</th>
                </tr>
            </thead>
            <tbody>
                @{
                    foreach (var item in Model)
                    {
                        <tr id="@item.UnitId">
                            <td>@item.UnitName</td>
                            <td>@item.VehicleNum</td>
                            <td>@item.TaskNum</td>
                            <td>@item.BusyVehicleNum</td>
                            <td>@item.FreeVehiclieNum</td>
                            <td>@item.UnavailableVehicleNum</td>
                            <td>@item.MonthTrip</td>
                            <td>@item.MonthVolume</td>
                        </tr>
                    }
                }
            </tbody>
        </table>
        </div>
        <div style="text-align:right;margin-top:10px;">
            <input type="button" value="导出到excel" onclick="tableToExcel('各单位任务统计', 'unittasktable');" />
        </div>
    </div>
</div>
<script type="text/javascript">
    registertableevent();
</script>
